<template>
  <div class="container">
    <div class="header">
      <div>我</div>
      <NuxtLink to="/person/setting">
        <div class="icon-wrapper flex align-center">
          <van-icon name="setting-o" />
        </div>
      </NuxtLink>
    </div>
    <div class="person-info">
      <div class="flex align-center">
        <img class="avatar" :src="userInfo.avatar" alt="" />
        <div>
          <div class="name">用户 {{ userInfo.nickName }}</div>
          <div class="desc">
            简介:{{ userInfo.desc ? userInfo.desc : "暂无简介" }}
          </div>
        </div>
      </div>
      <div class="menu-wrapper flex">
        <div class="menu-item flex flex-column align-center justify-center">
          <div class="title">我的mock博</div>
          <div class="number">{{userInfoDetail.userBlogCount}}</div>
        </div>

        <NuxtLink to="/person/favor" class="menu-item flex flex-column align-center justify-center">
          <div class="title">我的关注</div>
          <div class="number">{{userInfoDetail.favorCount}}</div>
        </NuxtLink>
      
        <div class="menu-item flex flex-column align-center justify-center">
          <div class="title">粉丝</div>
          <div class="number">{{userInfoDetail.beFavorCount}}</div>
        </div>
      </div>
      <van-button size="small" class="exit-btn" @click="exit" round block>
        退出登录
      </van-button>
    </div>
    <!-- 底部栏 -->
    <van-tabbar
      :value="4"
      active-color="#f55555"
      inactive-color="#333"
      placeholder
    >
      <van-tabbar-item icon="home-o">
        <NuxtLink to="/">博mock </NuxtLink>
      </van-tabbar-item>
      <van-tabbar-item icon="video-o"> 视频 </van-tabbar-item>
      <van-tabbar-item icon="search"> 发现 </van-tabbar-item>
      <van-tabbar-item icon="chat-o"> 消息 </van-tabbar-item>
      <van-tabbar-item icon="contact">
        <NuxtLink to="/person"> 我 </NuxtLink>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  auth: true,
  async fetch() {
    const res = await this.$axios.get("/v1/user/getUserInfoDetail");
    if (res && res.data.code == 200) {
      this.userInfoDetail = res.data.result;
    }
  },
  data() {
    return {
      userInfoDetail: {},
      userInfo:{}
    };
  },
  methods: {
    //退出登录
    exit() {
      this.$cookies.removeAll();
      this.$store.commit("setLogin", false);
      this.$router.replace("/login");
    },
  },
  created() {
    this.userInfo = this.$cookies.get("userInfo");
  },
};
</script>

<style lang="scss" scoped>
.container {
  background: #eee;
  min-height: 667px;
  .header {
    position: relative;
    height: 45px;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    background: #fff;
    line-height: 45px;
    .icon-wrapper {
      position: absolute;
      padding: 0 10px;
      right: 0;
      top: 0;
      height: 100%;
    }
  }
  .menu-wrapper{
    margin-top: 20px;
    .menu-item {
      border-right: 1px solid #eee;
      &:last-child{
        border-right: none;
      }
      flex: 1;
      .title{
        font-size: 16px;
      }
      .number{
        margin-top: 10px;
        font-size: 14px;
      }
    }
  }
  .person-info {
    margin-top: 10px;
    padding: 10px 10px 50px 10px;
    background: #fff;
    min-height: 562px;
    box-sizing: border-box;
    .avatar {
      margin-right: 10px;
      height: 50px;
      width: 50px;
      border-radius: 50%;
    }
    .name {
      font-size: 16px;
      line-height: 24px;
      font-weight: bold;
      color: #333;
    }
    .desc {
      font-size: 12px;
      line-height: 20px;
    }
    .exit-btn {
      position: absolute;
      bottom: 60px;
      left: 20px;
      right: 20px;
      width: 335px;
      font-size: 14px;
      margin-top: 20px;
      color: #f55555;
      border-color: #f55555;
      background: #fff;
    }
  }
}
</style>